package com.tx.springboot_demo.controller;

import com.tx.springboot_demo.domain.Book;
import com.tx.springboot_demo.service.IBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author ：tx
 * @description：book控制层
 * @date ：Created in 2019/4/10 13:57
 * @modified By：
 * @version:1.0
 */
@Controller
@RequestMapping("/bookController")
public class BookController {

    @Autowired
    IBookService bookService;

    @RequestMapping("/add")
    public void addBook(Book book){
        bookService.addBook(book);
    }

    @RequestMapping("/delete")
    public void deleteBook(Book book){
        bookService.deleteBook(book);
    }

    @RequestMapping("/update")
    public void updateBook(Book book){
        bookService.updateBook(book);
    }

    @RequestMapping("/findAll")
    @ResponseBody
    public List<Book> findBooks(){
        List<Book> books = bookService.findBooks();
        return books;
    }
}
